package com.yizn.learn.springext.getspringcontex.BeanFactoryAware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Service;

/**
 * project : my-learn
 * <p> 2.获取Spring容器对象 </p>
 * <p> 2.1 BeanFactoryAware接口 </p>
 *
 * @author yisl
 * @date 2023-01-13【星期五】
 **/
@Service
public class PersonService implements BeanFactoryAware {
    private BeanFactory beanFactory;
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }
    public void add(){
        Person person = (Person) this.beanFactory.getBean("person");
        person.test();
    }
}
